{extend name="public/base"/}
{block name="body"}
<div class="main-box no-header clearfix">
	<header class="main-box-header clearfix">
		<div class="pull-left">
			<h2>{$meta_title}（{$count}）</h2>
		</div>
		<div class="pull-right">
			<!-- <a href="{:url('add')}" class="btn btn-primary pull-right"> <i class="fa fa-plus-circle fa-lg"></i> 新增</a> -->
		</div>
	</header>
	<div class="main-box-body clearfix">

		<div class="row">
			<form method="get">
				<div class="col-sm-12 col-md-4 col-lg-2">
					<input type="text" class="form-control" name="out_trade_no" value="{$Think.get.out_trade_no}" placeholder="订单号">
				</div>
				<div class="col-sm-12 col-md-4 col-lg-2">
					<input type="text" class="form-control" name="wxname" value="{$Think.get.wxname}" placeholder="请输入微信名/用户名/手机">
				</div>
				<div class="col-sm-12 col-md-4 col-lg-2">
					<select name="rebate_code" id="category" class="form-control">
								<option value="">全部</option>
								{volist name=":getFlGroupUsers()" id="vo"}
									<option {eq name="$vo['uid']" value="$Think.get.rebate_code"}selected{/eq}  value="{$vo.uid}">{$vo.username}</option>
								{/volist}
					</select>
				</div>
				<div class="col-sm-12 col-md-4 col-lg-2">
					<input type="text" class="form-control" name="start" value="{$Think.get.start}" placeholder="开始时间">
				</div>
				<div class="col-sm-12 col-md-4 col-lg-2">
					<input type="text" class="form-control" name="end" value="{$Think.get.end}" placeholder="结束时间">
				</div>
				<div class="col-sm-12 col-md-4 col-lg-2" >
					<select name="pay" id="category" class="form-control">
								<option value="">全部</option>
								{volist name=":config('pay')" id="vo"}
									<option {eq name="$key" value="$Think.get.pay"}selected{/eq} value="{$key}">{$vo}</option>
								{/volist}
					</select>
				</div>
				<div class="col-sm-12 col-md-4 col-lg-2" >
					<select name="index_type" id="category" class="form-control">
								<option value="" >商品模块</option>
								{volist name=":config('indextype')" id="vo" }
									<option {php}  if($_GET['index_type'] != ''){
																				if(intval($_GET['index_type']) === $key){echo 'selected';};
																			}  {/php}  value="{$key}">{$vo}



									 </option>
								{/volist}
					</select>
				</div>
				<div class="col-sm-12 col-md-4 col-lg-2" >
					<select name="ztz" id="category" class="form-control">
								<option value="" >自提站</option>
								{volist name="$ztzlist" id="vo" }
									<option {php}  if($_GET['ztz'] != ''){
																				if(intval($_GET['ztz']) == $vo.name){echo 'selected';};
																			}  {/php}  value="{$vo.name}">{$vo.name}



									 </option>
								{/volist}
					</select>
				</div>
				<div class="col-sm-12 col-md-4 col-lg-2" >
					<select name="psy" id="category" class="form-control">
								<option value="" >配送员</option>
								{volist name="$psylist" id="vo" }
									<option {php}  if($_GET['psy'] != ''){
																				if(intval($_GET['psy']) == $vo['id']){echo 'selected';};
																			}  {/php}  value="{$vo.id}">{$vo.name}



									 </option>
								{/volist}
					</select>
				</div>


				<br />
				<div class="col-sm-12 col-md-4 col-lg-12" style="    text-align: right;    margin-top: 10px;">
					<a class="btn btn-primary" href="{:url('order/createNewsStraightToExl')}">生产产地订单</a> <button class="btn btn-primary" type="submit">搜索</button>
				</div>
			</form>
		</div>


		<div class="table-responsive">
      <table class="table table-striped table-hover">
        <thead>
          <tr>
            <th width="30"><input class="checkbox check-all" type="checkbox"></th>
            <th width="60">ID</th>
            <th>订单号</th>
            <th>微信名称</th>
            <th>用户名</th>
            <th>商品总价格({$shopsSum})</th>
            <th>余额和优惠券合计({$balanceCoupoSum})</th>
            <th>运费({$freightSum})</th>
            <th>打包费({$packPriceSum})</th>
            <th>实际支付({$payPriceSum})</th>
            <th>订单总额({$sum})</th>
            <th>送货方式</th>
            <th>付款方式</th>
            <th>下单时间</th>
						<th>返利用户</th>
						<th>状态</th>
            <th>操作</th>
          </tr>
        </thead>
        <tbody>
          {volist name="list" id="item"}
          <tr>
            <td><input class="ids row-selected" type="checkbox" name="ids[]" value="{$item['id']}"></td>
            <td>{$item['id']}</td>
            <td>{$item['out_trade_no']}</td>
            <td>{$item['nick_name']} </td>
            <td>{$item['user_name']} </td>
            <td>{$item['shop_price']} </td>
            <td>{$item['balance'] + $item['coupon_price']} </td>
						<td>
							{$item['freight']}
						</td>
						<td>
							{$item['pack_price']}
						</td>
            <td>{$item['pay_price']} </td>
            <td>{$item['total']} </td>
						<td>{$item['way']|parse_config_value='distribution'}</td>
						<td>{$item['pay']|parse_config_value='pay'} {eq name="$item.index_type" value="2"}(产地直发){/eq} {$item['offlinepay_status']? '（实体扫码）' : ''}

						</td>
						<td>{$item['create_time']}</td>
						<td>{$item['rebate_code']|get_table_field="uid","username","member"}</td>
						<td>{$item['buystatus']|parse_config_value='pay_status'}</td>

            <td>
              <a href="{:url('edit',array('id'=>$item['id']))}">编辑</a>
              <a href="{:url('del',array('id'=>$item['id']))}" class="confirm ajax-get">删除</a>

							<a href="javascript:;" url="{:url('wechat/wechatIsPay',array('out_trade_no'=>$item['out_trade_no']))}"  class="ispay">核对微信付款</a>


            </td>
          </tr>
          {/volist}
        </tbody>
      </table>
			{$list->render()}
		</div>
	</div>
</div>


<!-- 模态框（Modal） -->
<div class="modal fade" id="isPay" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="myModalLabel">核对消息</h4>
            </div>
            <div class="modal-body"></div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>



<!-- datepicker statr -->
<link href="__PUBLIC__/plugs/datepicker/css/foundation-datepicker.min.css" rel="stylesheet" type="text/css">
<script src="__PUBLIC__/plugs/datepicker/js/foundation-datepicker.js"></script>
<script src="__PUBLIC__/plugs/datepicker/js/foundation-datepicker.zh-CN.js"></script>
<link rel="stylesheet" type="text/css" href="__PUBLIC__/plugs/board/board.min.css">
<!-- datepicker end -->
<script type="text/javascript">
		$('[name="start"]').fdatepicker({
			format: 'yyyy-mm-dd hh:ii',
			pickTime: true
		});
		$('[name="end"]').fdatepicker({
			format: 'yyyy-mm-dd hh:ii',
			pickTime: true
		});

		// implementation of disabled form fields
		// var nowTemp = new Date();
		// var now = new Date(nowTemp.getFullYear(), nowTemp.getMonth(), nowTemp.getDate(), 0, 0, 0, 0);
		// var checkin = $('[name="start"]').fdatepicker({
		// 	format: 'yyyy-mm-dd',
		// }).on('changeDate', function (ev) {
		// 	if (ev.date.valueOf() > checkout.date.valueOf()) {
		// 		var newDate = new Date(ev.date)
		// 		newDate.setDate(newDate.getDate() + 1);
		// 		checkout.update(newDate);
		// 	}
		// 	checkin.hide();
		// 	$('[name="end"]')[0].focus();
		// }).data('datepicker');
		// var checkout = $('[name="end"]').fdatepicker({
		// 	format: 'yyyy-mm-dd',
		// 	onRender: function (date) {
		// 		return date.valueOf() <= checkin.date.valueOf() ? 'disabled' : '';
		// 	}
		// }).on('changeDate', function (ev) {
		// 	checkout.hide();
		// }).data('datepicker');

		var shopsau = "{$shopsau}"
		if(shopsau){
			$('[name="rebate_code"]').parent().remove();
			$('[name="pay"]').parent().remove();
			$('[name="index_type"]').parent().remove();
		}


		ispayUrl = ''
		$('.ispay').click(function(){
			$('#isPay').modal('show')
			ispayUrl = $(this).attr('url')
		})
		$('#isPay').on('shown.bs.modal', function () {
			var $this = $(this)

			 $.get(ispayUrl, function(data){
				 console.log(data);
			 		 $this.find('.modal-body').html(data.msg+',微信支付订单号	：'+data.data.transaction_id+',支付金额：'+(data.data.cash_fee/100))
			 })
		})


</script>


{/block}
